// pages/button3/button3.js
Page({

  data: {
    name: '关羽',
    age: 1000,
    aihao: '耍大刀',
    userinfo: {
      name: '张飞',
      age: 999,
      aihao: '喝酒'
    },
    score:70,
    animals: ["猫", '狗', '大象'],
    showimg:true,
    planlist:[
      { "id": 1,
        "plan_name": "买3赠1",
        "is_active": 12
      },
      {
        "id": 2,
        "plan_name": "满100元立减10元",
        "is_active": 15
      },
      {
        "id": 3,
        "plan_name": "满100元9折",
        "is_active": 100
      },
      {
        "id": 4,
        "plan_name": "会员日特价",
        "is_active": 1
      },
      {
        "id": 5,
        "plan_name": "会员特价",
        "is_active": 1
      },
      {
        "id": 6,
        "plan_name": "满200送50",
        "is_active": 1
      },
      {
        "id": 7,
        "plan_name": "周五特价红标",
        "is_active": 1
      }
    ],
  },
  addage() {
    // console.log(this.data.age)
    // this.data.age+=1
    console.log(this.data.userinfo.age)
    let a = 2
    this.setData({ 'userinfo.age': this.data.userinfo.age += a })
    const user = { ...this.data.userinfo, sex: '男', math: 90 }
    this.setData({ userinfo: user })
    this.setData({ 'userinfo.math': this.data.userinfo.math += 1 })
  },
  addanimals() {
    // this.data.animals.push('长颈鹿')
    // this.setData({animals:this.data.animals})
    // const newanimals=[...this.data.animals,'老虎']
    let newanimals = this.data.animals.concat('狮子')
    this.setData({ animals: newanimals })
    this.setData({ 'animals[0]': '熊猫' })
    this.setData({ animals: this.data.animals.slice(1) })
  },

  handleshowimg(){
    // console.log(this.data.showimg)
    this.setData({showimg:!this.data.showimg})

  },
  netloaduser(){
    wx.showLoading({
      title: '加载中...',
      mask:true
    })
    wx.request({
      url: 'http://8005.qizb.com',
      method:'GET',
      data:{},
      header:{},
      success:(res)=>{
        console.log(res.data)
        this.setData({user:res.data})
      },
      fail:(error)=>{
        console.log(error)
      },
      complete:(res)=>{
        wx.hideLoading()
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})